<%@ page import="com.viking.car.Message" %>
<%@page language="java" contentType="text/html; UTF-8"  pageEncoding="UTF-8" %>
<html>
<head>
         <style>
             div{
                 text-align: left;
                 color: red;
             }
         </style>
    <script type="text/javascript" src="/js/jquery-1.7.min.js"></script>

</head>
<body>
<form>
    <center><table>
        <tr>
            <td>IP</td>
            <td><input type="text" name="ip" value="localhost" size="34"/></td>
        </tr>
        <tr>
            <td>端口</td>
            <td><input type="text" name="port" value="7980" size="34"/></td>
        </tr>

        <tr>
            <td>token类型</td>
            <td><input type="text" name="type" maxlength="1" value="1" size="34"/></td>
        </tr>
        <tr>
            <td>订单编号</td>
            <td><input type="text" name="orderNo" maxlength="32" value="000000000F2014031812000814648141" size="34"/></td>
        </tr>
        <tr>
            <td>用户编号</td>
            <td><input type="text" name="userId" maxlength="32" value="0907e7826f744542b492bbd3596439db" size="34"/></td>
        </tr>
        <tr>
            <td>车辆编号</td>
            <td><input type="text" name="carId" maxlength="17" value="WBA3A5507CNN00000" size="34"/></td>
        </tr>
        <tr>
            <td>订单开始时间</td>
            <td><input type="text" name="orderStartDt" maxlength="14" value="20140321093000" size="34"/></td>
        </tr>
        <tr>
            <td>允许的订单开始时间向前偏移量</td>
            <td><input type="text" name="orderStartDtOff" maxlength="4" value="0900" size="34"/></td>
        </tr>
        <tr>
            <td>订单结束时间</td>
            <td><input type="text" name="orderEndDt" maxlength="14" value="20150321093000" size="34"></td>
        </tr>
        <tr>
            <td>允许的订单结束时间向后偏移量</td>
            <td><input type="text" name="orderEndDtOff" maxlength="4" value="0900" size="34"></td>
        </tr>
        <tr>
            <td>
                <select name="commandId">
                    <option value="1">取车</option>
                    <option value="2">开门</option>
                    <option value="3">锁门</option>
                    <option value="4">还车</option>
                    <option value="5">查询电量</option>
                </select>
            </td>
            <td><input type="button" name="btn"  value="提交" onclick="submit2(this.form)"></td>
        </tr>

    </table></center>

    <div id="result">


    </div>
</form>

<script type="text/javascript">
    function submit2(form){
        form.btn.disabled =true;
        var url = "/execute";
        var ip = form.ip.value;
        var port = form.port.value;
        var type = form.type.value;
        var orderNo = form.orderNo.value;
        var userId = form.userId.value;
        var carId = form.carId.value;
        var orderStartDt = form.orderStartDt.value;
        var orderStartDtOff = form.orderStartDtOff.value;
        var orderEndDt = form.orderEndDt.value;
        var orderEndDtOff = form.orderEndDtOff.value;
        var commandId= form.commandId.value;
        $.post( url,
                {
                    ip:ip,
                    port:port,
                    type:type,
                    orderNo:orderNo,
                    userId:userId,
                    carId:carId,
                    orderStartDt:orderStartDt,
                    orderStartDtOff:orderStartDtOff,
                    orderEndDt:orderEndDt,
                    orderEndDtOff:orderEndDtOff,
                    commandId:commandId
                },
                function(data){
                    var $resp = $("#result");
                    $resp.html(data);
                    form.btn.disabled =false;
                }).error(function(err) {
                    form.btn.disabled =false;
                    var $resp = $("#result");
                    $resp.html("status："+err["status"]+
                            "<br/>statusText:"+err["statusText"]);
                });
    }
</script>
</body>
</html>
